<%@page import="com.billing.model.entity.Message"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String type=request.getAttribute("type").toString();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>查看客户</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">
	<link href="<c:url value="/css/page.css"/>" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/jquery.datetimepicker.css"/>"/>
	<link href="<c:url value="/css/navuser.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/but.css"/>" rel="stylesheet">
	<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
	<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/layer/layer.js"/>"></script>
	<script src="<c:url value="/js/laydate/laydate.js"/>"></script>
	<script src="<c:url value="/js/build/jquery.datetimepicker.full.js"/>"></script>
	<script src="<c:url value="/js/orgin.js"/>"></script>
	<script src="<c:url value="/js/filebut.js"/>"></script>
	
	<script src="../../../../scripts/boot.js" type="text/javascript"></script>
    <script src="http://kindeditor.net/ke4/kindeditor-all-min.js?t=20160331.js" type="text/javascript"></script>
</head>
 <script type="text/javascript">
 function save(){
	 var consultingtitle = $("#consultingtitle").val();//标题
	 var outline = $("#outline").val();//摘要
	 var articletypeid = $("#articletypeid").val();//类型
	 if(consultingtitle == null || consultingtitle == ""){
		 alert("请输入标题！");
		 return;
	 }
	 if(outline == null || outline == ""){
		 alert("请输入摘要！");
		 return;
	 }
	 if(articletypeid == null || articletypeid == ""){
		 alert("请输入类型！");
		 return;
	 }
	 if((editor.html().length-12) <= 0){
		 alert("请输入内容！");
		 return;
	 }
	 
	 getContent();
	 $("#customerform").submit();
 }
 
 function beyond(){
	 var outline = $("#outline").val();
	 var showText = document.getElementById("outline");
	 if(outline.length > 80){
		 showText.style.color = "red";
		 alert("摘要超出最大输入字数80！！！")
		 return;
	 }else{
	 	showText.style.color = "black";
	 }
 }
 
 $(function(){ 
	 var msg="${msg}";
	 if(msg!=null&&msg!=""){
		 alert(msg);
         closebutton();
         window.parent.location.reload(); //刷新父页面
	 }
 }); 
 
 $(function(){
	 laydate.render({
		  elem: '#starttime'
		  ,type: 'date'
		  ,format: 'yyyy-MM-dd'
		});
	 laydate.render({
		  elem: '#endtime'
		  ,type: 'date'
		  ,format: 'yyyy-MM-dd'
		});
 });
 
 //返回
 function reback(){
     var url='<%=basePath%>message/mainpage';
     parent.$("#mainFrame").attr("src",url);
 }
 
 //取消
 function closebutton() {
		var index = parent.layer.getFrameIndex(window.name);  
	 	parent.layer.close(index);  
}
 
function lookimg(path){
    layer.open({
		title: '图片',
       type: 2,
       area: ['800px', '560px'],
       fixed: false, //不固定
       maxmin: true,
       content: '<%=basePath%>message/imgmain?path='+path
     });
}
</script>
<body>
<div id="content" class="span10" style="background-color:#F9F9F9;">
<div style="background-color:#FFF">
<form name="customerform" id="customerform" method="post" enctype="multipart/form-data" action="<%=basePath%>message/conseditlookupdate">
	<input type="hidden" id = "id" name="id" value="${conlist.id }">
	<input type="hidden" id = "huserid" name="huserid" value="${conlist.userid }">
	<input type="hidden" id = "type" name="type" value="<%=type %>">
	<input type="hidden" id="addeddate" name="addeddate" value="${conlist.addtime }">
	<input type="hidden" id="harticle" name="harticle" value="">
	<table>
			<tr>
				<td>标题：</td>
				<td colspan = "3">
					<%if(type.equals("1")) {%>
						<input style="width: 100%;" type="text" id="consultingtitle" name="consultingtitle" value="${conlist.consultingtitle }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<%}else{ %>
						<input readonly="readonly" style="width: 100%;" type="text" id="consultingtitle" name="consultingtitle" value="${conlist.consultingtitle }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<%} %>
				</td>
			</tr>
			<tr>
				<td>摘要：</td>
				<td colspan = "3">
					<%if(type.equals("1")) {%>
						<input style="width: 100%;" onkeyup="beyond();" type="text" id="outline" name="outline" value="${conlist.outline }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<%}else{ %>
						<input style="width: 100%;" readonly="readonly" type="text" id="outline" name="outline" value="${conlist.outline }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<%} %>
				</td>
			</tr>
			<tr>
				<td>作者：</td>
				<td>
					<%if(type.equals("1")) {%>
						<input type="text" id="writer" name="writer" value="${conlist.writer }">
					<%}else{ %>
						<input readonly="readonly" type="text" id="writer" name="writer" value="${conlist.writer }">
					<%} %>
				</td>
				<td>内容类型：</td>
				<td>
					<%if(type.equals("1")) {%>
					<select name="articletypeid" id="articletypeid" class="buildselect">
						<option value="">请选择</option>
						<c:forEach items="${articletypelist }" var="a">
							<option value="${a.id }"  ${a.id==conlist.articletypeid?'selected':''}>${a.name }</option>
						</c:forEach> 
					</select>
					<%}else{ %>
						<select name="articletypeid" id="articletypeid" class="buildselect">
						<option value="">请选择</option>
						<c:forEach items="${articletypelist }" var="a">
							<option disabled="disabled" value="${a.id }"  ${a.id==conlist.articletypeid?'selected':''}>${a.name }</option>
						</c:forEach> 
					</select>
					<%} %>
				</td>
			</tr>
			<tr>
				<td>来源：</td>
				<td>
					<%if(type.equals("1")) {%>
						<input type="text" id="belonging" name="belonging" value="${conlist.belonging }">
					<%}else{ %>
						<input readonly="readonly" type="text" id="belonging" name="belonging" value="${conlist.belonging }">
					<%} %>
				</td>
				<td>来源地址：</td>
				<td>
					<%if(type.equals("1")) {%>
						<input type="text" id="sourceaddress" name="sourceaddress" value="${conlist.sourceaddress }">
					<%}else{ %>
						<input readonly="readonly" type="text" id="sourceaddress" name="sourceaddress" value="${conlist.sourceaddress }">
					<%} %>
				</td>
			</tr>	
			<%-- <tr>
				<td>上传照片：</td>
				<td colspan = "3">
					<div style="width:33%;float:left;">
						<c:if test="${conlist.path != '' && conlist.path !=null}">
							<span>照片：</span><a onclick="lookimg('${conlist.path}');">查看</a>
						</c:if>
					</div>
				</td>
			</tr> --%>
			<tr>
				<td>内容：</td>
				<td colspan = "3">
				   <%if(type.equals("1")) {%>
						<div class="mini-panel" title="表单" style="width:680px;height:300px;" showCollapseButton="true">
				        <div name="editor" id="editor" rows="10" cols="80" style="height:280px;">
							   <p>${conlist.article}</p>
				        </div>
				        </div>
				            <button style="background-color: #dadada;color: #666;" type="button" onclick="setDisabled();" id="output1">设置编辑器只读</button>
					        <button style="background-color: #dadada;color: #666;" type="button" onclick="setEnabled();" id="output1">取消编辑器只读</button>
				        	<button style="background-color: #dadada;color: #666;" type="button" onclick="getContent();" id="output1">获取编辑器的值</button>
				        <script type="text/javascript">
						    var editor = KindEditor.create('#editor');
						    function setDisabled() {editor.readonly();}
						    function setEnabled() {editor.readonly(false);}
						    function getContent() {
						    	var f = editor.html();
						    	$("#harticle").val(f);
					    	}
						</script>
					<%}else{ %>
						<div class="mini-panel" title="表单" style="width:680px;height:300px;" showCollapseButton="true">
				        <div name="editor" id="editor" rows="10" cols="80" style="height:280px;">
							   ${conlist.article}
				        </div>
				        </div>
				        <script type="text/javascript">
						    var editor = KindEditor.create('#editor');
						    $(function(){editor.readonly();});
						</script>
					<%} %>
				</td>
			</tr>
	</table>
</form>
<div class="row-fluid content-table">
<table class="table  bootstrap-datatable" style=" border:none; border-spacing:0; border-collapse:collapse;margin:0;padding:0;">
	<tbody>
		<tr class="content-search" style="text-align: center;">
			<td colspan="6">
			    <%if(type.equals("1")) {%>
					<div>
						<button style="background-color: #dadada;color: #666;" type="button" onclick="closebutton();" id="output1">取消</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<button class="but" onclick="save();">提交</button>
					</div>
				<%}if(type.equals("2")){ %>
					<div>
						<button style="background-color: #dadada;color: #666;" type="button" onclick="closebutton();" id="output1">关闭</button>
					</div>
				<%}%>
			</td>
		</tr>
	</tbody>
</table>            
</div>
</div>
</div>	
</body>
</html>
